/*作业1：按照首字母顺序排序*/




    #include <stdio.h>  
    #include <string.h>  
    //冒泡排序法

    void Sort(char *buffer[], int size) 
    {  

        for (int idx = 0; idx  < size - 1; idx ++)
        {  
            for (int jdx = 0; jdx  < size - idx - 1; jdx ++) 
            {  
                if (strcmp(buffer[jdx], buffer[jdx + 1]) > 0)
                {  
                    // 交换 buffer[j] 和 buffer[j + 1]  
                    char *temp = buffer[jdx];  
                    buffer[jdx] = buffer[jdx + 1];  
                    buffer[jdx + 1] = temp;  
                }  
            }  
        }  
    }  
    
    int main() 
    {  
        char *buffer[] = {"zhangsan", "lisi", "wangwu", "huiyi", "shouji"};  
        int size = sizeof(buffer) / sizeof(buffer[0]);  
    
        Sort(buffer, size);  
    
        // 打印排序后的数组  
        for (int idx = 0; idx < size; idx++) 
        {  
            printf("%s\n", buffer[idx]);  
        }  
    
        return 0;  
    }